//
//  LPDCDetailModel.m
//  LovingPartyBuilding
//
//  Created by 刘应平 on 17/5/6.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "LPDCDetailModel.h"

@implementation LPDCDetailModel



- (CGFloat)height{
    CGFloat width;
    NSString *title = self.TITLE;
    /**  通过不同类型去不同的宽度，计算高度  */
    if ([self.DISPLAY isEqualToString:@"1"]) {
        /**  左图右文字  */
        width = [UIScreen zj_screenWith] * 0.65 - 40 * [UIScreen zj_screenWScale];
        
    }else if ([self.DISPLAY isEqualToString:@"2"]){
        /**  大图  */
        width = [UIScreen zj_screenWith] - 30 * [UIScreen zj_screenWScale];
    }else if ([self.DISPLAY isEqualToString:@"3"]){
        /**  多图  */
        width = [UIScreen zj_screenWith] - 30 * [UIScreen zj_screenWScale];
    }else{
        title = self.SUBTITLE;
        /**  纯文字  */
        width = [UIScreen zj_screenWith] - 30 * [UIScreen zj_screenWScale];
    }
    
   return  [CalculateLabelHeight calculateLabeHeightWithString:title font:15 * [UIScreen zj_textFontScale] width:width space:4 * [UIScreen zj_screenHScale]];
}

- (NSString *)SUBTITLE{
    CGFloat one = [CalculateLabelHeight CalculateLabelWidthWithString:@"党" font:15 *[UIScreen zj_textFontScale] height:15 * [UIScreen zj_screenHScale]].width;
    
    CGFloat time = [CalculateLabelHeight CalculateLabelWidthWithString:@"(2016-11-01)" font:15 *[UIScreen zj_textFontScale] height:15 * [UIScreen zj_screenHScale]].width + 30 * [UIScreen zj_screenWScale];
    CGFloat total = [UIScreen zj_screenWith] * 2 - 60 * [UIScreen zj_screenWScale] - time;
    NSInteger number = total / one;
    if (self.TITLE.length > number) {
        return [self.TITLE substringToIndex:number];
    }else{
        return self.TITLE;
    }
    
}

- (void)setABSTRACT:(NSString *)ABSTRACT{
    _ABSTRACT = ABSTRACT;
     self.IKnowedgeContentHeight = [CalculateLabelHeight calculateLabeHeightWithString:ABSTRACT font:14 * [UIScreen zj_textFontScale] width:[UIScreen zj_screenWith] * 0.6 - 40 * [UIScreen zj_screenWScale] space:3 * [UIScreen zj_screenHScale]];
}


- (CGFloat)CELLHEIGHT{
    CGFloat height = 0.0;
    if ([self.DISPLAY isEqualToString:@"3"]) {
        height =  210 * [UIScreen zj_screenHScale] + self.height;
    }else if ([self.DISPLAY isEqualToString:@"1"]){
        height =  115 * [UIScreen zj_screenHScale];
    }else if ([self.DISPLAY isEqualToString:@"2"]){
        /**  默认高度  */               /**  图片高度  */
        if (self.height > 20 * [UIScreen zj_screenHScale]) {
            height =  50 * [UIScreen zj_screenHScale] + self.height + 70 * [UIScreen zj_screenHScale] ;
        }else{
            height =  70 * [UIScreen zj_screenHScale] + 70 * [UIScreen zj_screenHScale];
        }
        
    }else{
       
         height = 60 * [UIScreen zj_screenHScale];
    }
    return height;
}
@end
